/*
 * @lc app=leetcode.cn id=153 lang=java
 *
 * [153] 寻找旋转排序数组中的最小值
 */

// @lc code=start
class Solution {
    public int findMin(int[] nums) {
        if(nums == null || nums.length == 0) return 0;

        int len = nums.length;
        if(len == 1) return nums[0];

        int left = 0, right = len - 1;

        while(left < right){
            int mid = left + (right - left) / 2;
            // 与右边界比较
            if(nums[mid] > nums[right]){
                left = mid + 1;
            }else if (nums[mid] < nums[right]){
                right = mid;
                
            } else{
                right--;
            }
        }
        return nums[left];
    }
}
// @lc code=end

